Statically tracking state with Typed Regions
نویسنده
چکیده
Static type systems have proved to be tremendously effective formal systems, making specification and verification sufficiently lightweight and intuitive that most programmers use them without even realizing it. Not only that, but they have shown to adapt very well to most modern language features. The downside is that the properties one can express and verify with garden variety type systems is fairly limited, especially concerning properties which depend on side-effects and tracking the state of objects. Such properties usually require the use of other formal methods, such as some kind of Hoare logic [Hoare 1969; Reynolds 2002], which are targeted specifically at reasoning about imperative programs. And it so happens that those alternative formal methods do not always integrate well with modern language features such as higher-order functions, and polymorphism. The work presented here presents a new type system which has an expressive power comparable to that of a Hoare logic, thus hopefully combining the best of both worlds. As the technology of certifying compilation and proof carrying code [Necula 1997; Appel 2001; Hamid et al. 2002] progresses, the need to ensure the correctness of the runtime system increases: the carefully designed proof system risks breaking down completely if one of the primitives of the runtime system does not behave exactly as intended. The best way to approach this problem is to trim down the trusted part of the runtime system, starting with the garbage collector. For this reason, it is important to be able to write a verifiably type-safe GC, which may come bundled with the application code, rather than hard-coded in the trusted runtime system. but the state of the art in this matter is still very much impractical. So one of this paper’s main goal is to present a type system that is sufficiently flexible and powerful to type-check low-level code such as stack manipulation, pointer reversal, or the various parts of a generational garbage collector. This type system provides a form of assignment that can change the type of a location (i.e. a strong update [Chase et al. 1990]) even if the set of aliases to this location is not statically known, and it allows the programmer to choose any mix of linear or intuitionistic typing of references and to seamlessly change this choice over time to adapt it to the current needs. Traditional type systems are not well-suited to reason about type safety of low-level memory management such as explicit memory allocation, initialization, deallocation, or reuse. Existing solutions to these problems either have a very limited applicability or rely on some form of linearity constraint. Such constraints tend to be inconvenient and a lot of work has gone into relaxing them. For example, the alias types system [Walker and Morrisett 2000] is able to cleanly handle several of the points above, even in the presence of arbitrary aliasing, as long as the aliases can be statically tracked by the type system. Traditional type systems mostly ensure memory safety. But of course, when typing low-level memory management code, proving that the code does not break the memory safety invariants often amounts to the same as proving that the code is correct. For this
منابع مشابه
Monotonic References for Efficient Gradual Typing
Gradual typing enables both static and dynamic typing in the same program and makes it convenient to migrate code regions between the two typing disciplines. One goal of gradual typing is to provide all the benefits of static typing, such as efficiency, in statically-typed regions. However, this goal is elusive: the standard approach to mutable references imposes run-time overhead in statically...
متن کاملStatic type information to improve the IDE features of hybrid dynamically and statically typed languages
The flexibility offered by dynamically typed programming languages has been appropriately used to develop specific scenarios where dynamic adaptability is an important issue. This has made some existing statically typed languages gradually incorporate more dynamic features to their implementations. As a result, there are some programming languages considered hybrid dynamically and statically ty...
متن کاملSelf-Interpretation and Reflection in a Statically Typed Language
Reflection is the ability of a system to perform a computation about itself. This ability typically includes a way of representing programs as data (“reification”) and of executing representations of programs (“selfinterpretation”). The interpreter is accessible to the interpreted program in the form of an “eval” function. Reflection is traditionally studied in untyped or dynamically typed lang...
متن کاملExploring the Design Space of Higher-Order Casts
This paper explores the surprisingly rich design space for the simply typed lambda calculus with casts and a dynamic type. Such a calculus is the target intermediate language of the gradually typed lambda calculus but it is also interesting in its own right. In light of diverse requirements for casts, we develop a modular semantic framework, based on Henglein’s Coercion Calculus, that instantia...
متن کاملExploring the Design Space of Higher-Order Casts ; CU-CS-1047-08
This paper explores the surprisingly rich design space for the simply typed lambda calculus with casts and a dynamic type. Such a calculus is the target intermediate language of the gradually typed lambda calculus but it is also interesting in its own right. In light of diverse requirements for casts, we develop a modular semantic framework, based on Henglein’s Coercion Calculus, that instantia...
متن کاملType Inference to Optimize a Hybrid Statically and Dynamically Typed Language
Dynamically typed languages are becoming increasingly popular for different software development scenarios such as Web engineering, rapid prototyping, or the construction of applications that require runtime adaptiveness. In contrast, statically typed languages have undeniable advantages such as early type error detection and more opportunities for compiler optimizations. Since both approaches ...
متن کامل